﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TipCalc.Business
{
    public class Bill
    {

        #region Properties

        private decimal _billAmount;
        public decimal BillAmount 
        {
            get
            {
                return _billAmount;
            }
            set
            {
                if (value < 0)
                {
                    throw new ArgumentOutOfRangeException();
                }
                _billAmount = value;
            }
        }

        private decimal _tipPercentage;
        public decimal TipPercentage 
        {
            get
            {
                return _tipPercentage;
            }
            set
            {
                if (value < 0)
                {
                    throw new ArgumentOutOfRangeException();
                }
                _tipPercentage = value;
            }
        }

        public decimal TipAmount 
        { 
            get
            {
                //  Calculate tip amount and return result.
                return (Math.Round(BillAmount * (TipPercentage * .01m), 2, MidpointRounding.AwayFromZero));
            }
        }

        #endregion

    }
}
